package com.cty.B_AllocationAndCollection.A_Allocation;

/**
 * @Auther: cty
 * @Date: 2020/6/29 21:48
 * @Description: 对象优先在Eden区分配
 * @VM Args: -XX:+PrintGCDetails -Xms20m -Xmx20m -Xmn10m -XX:SurvivorRatio=8
 * @version: 1.0
 */
public class Allocation {

    public static final int _1MB = 1024 * 1024;

    public static void testAllocation(){
        byte[] allocation1, allocation2, allocation3, allocation4;
        allocation1 = new byte[2 * _1MB];
        allocation2 = new byte[2 * _1MB];
        allocation3 = new byte[2 * _1MB];
        allocation4 = new byte[4 * _1MB];  // 出现一次Minor GC
    }

    public static void main(String[] args) {
        testAllocation();
    }  // end main()

}  // end class

/**
 * [GC[DefNew: 7187K->419K(9216K), 0.0040928 secs] 7187K->6563K(19456K), 0.0041290 secs] [Times: user=0.02 sys=0.00, real=0.00 secs]
 * Heap
 *  def new generation   total 9216K, used 4845K [0x33a00000, 0x34400000, 0x34400000)
 *   eden space 8192K,  54% used [0x33a00000, 0x33e52730, 0x34200000)
 *   from space 1024K,  40% used [0x34300000, 0x34368f40, 0x34400000)
 *   to   space 1024K,   0% used [0x34200000, 0x34200000, 0x34300000)
 *  tenured generation   total 10240K, used 6144K [0x34400000, 0x34e00000, 0x34e00000)
 *    the space 10240K,  60% used [0x34400000, 0x34a00030, 0x34a00200, 0x34e00000)
 *  compacting perm gen  total 12288K, used 260K [0x34e00000, 0x35a00000, 0x38e00000)
 *    the space 12288K,   2% used [0x34e00000, 0x34e41088, 0x34e41200, 0x35a00000)
 *     ro space 10240K,  44% used [0x38e00000, 0x3927aee0, 0x3927b000, 0x39800000)
 *     rw space 12288K,  52% used [0x39800000, 0x39e42e10, 0x39e43000, 0x3a400000)
 */
